﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;

namespace GraphicsEditor
{
    class TextTool: DrawingTool
    {
        public TextTool()
        {
            //pixelDown = new Point(0, 0);
            //pixelUp = new Point(0,0);
        }
        public override void setMouseDown(Point mouseLoc, PictureBoxAdvance pictureWindow)
        {
            pixelDown = getPixelPositionUsingMouse(mouseLoc, pictureWindow);

            img = pictureWindow.Image; // saves image to be pushed to undo stack
        }
        public override void setMouseUp(Point mouseLoc, PictureBoxAdvance pictureWindow)
        {
            pixelUp = getPixelPositionUsingMouse(mouseLoc, pictureWindow);

            TextInput text = new TextInput();

            if (text.ShowDialog() == DialogResult.OK)
            {
                Bitmap newBitmap = new Bitmap(pictureWindow.Image);
                Graphics gfx = Graphics.FromImage(newBitmap);
                SolidBrush brush = new SolidBrush(ToolBox.selectedColor);
                Pen pen = new Pen(brush, ToolBox.PixelSize);
                gfx.DrawString(text.textBox1.Text, ToolBox.TBFont, brush, pixelUp);
                pictureWindow.Image = newBitmap;
                undoPushed = false;
            }
        }
        public override void mouseMoved(Point mouseLoc, PictureBoxAdvance pictureWindow, ImageForm imageform, bool mouseDown)
        {
            if (mouseDown && !undoPushed) // if mouse is clicked and undo has NOT been pushed to stack
            {
                imageform.undo(img); // push image to undo stack
                undoPushed = true;
            }
        }
        public override void paintSelection(Graphics gfx, PictureBoxAdvance pictureWindow, bool zoom)
        {

        }
    }
}
